home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / st80_pr4.lha / st80_pre4 / MoDE / Resize-Shan.st < prev    next >
Text File  |  1993-07-24  |  6KB  |  217 lines

  1. SemanticObject subclass: #ResizeDot
  2.     instanceVariableNames: 'resizingMode controlMessage '
  3.     classVariableNames: ''
  4.     poolDictionaries: ''
  5.     category: 'Resize-Shan'!
  6. ResizeDot comment:
  7. 'It is very unfortunate that I have to optimize the displaying of the resizeDots which makes the appearance of the dots not editable from the MMS.  The original version is totally implemented with the MMS structure.  The dot is displayed as a mode.  It is too slow and has to be replaced by the current version.  Shan June 14, 1989'!
  8.  
  9.  
  10. !ResizeDot methodsFor: 'controller-msg'!
  11.  
  12. action: e 
  13.     "Shan June 12, 1989"
  14.  
  15.     resizingMode controller perform: (controlMessage asString , 'Moved') asSymbol.
  16.     resizingMode changed: #moveResized! !
  17.  
  18. !ResizeDot methodsFor: 'MMS-initializations'!
  19.  
  20. setUpAppearance
  21.     "Shan July 21, 1989"
  22.  
  23.     super setUpAppearance.
  24.     mode extent: 5@5!
  25.  
  26. setUpController
  27.     "Shan June 6, 1989"
  28.  
  29.     | ctrl erDict |
  30.     ctrl _ ActionController new.
  31.     mode controller: ctrl! !
  32.  
  33. !ResizeDot methodsFor: 'updating'!
  34.  
  35. update: x 
  36.     "Put myself at the right position according to the new size or position 
  37.     of the resizingMode.  Here a trick is used.  The controlMessage is set 
  38.     to be the Rectangle accessing method names.  Shan June 13, 1989"
  39.  
  40.     | p oldDispBox newDispBox |
  41. "MessageTally spyOn: ["
  42.     x = #beforeErase ifTrue:[
  43.     "Erase self before the resizingMode does anything to the display.  Otherwise, the inverse of self won't erase myself. Shan June 14, 1989"
  44.     Display reverse: mode displayBox].
  45.     x = #moveResized ifTrue:[    p _ (resizingMode unclippedDisplayBox perform: controlMessage) rounded.
  46.     "Center mode to point p."
  47.     oldDispBox _ mode unclippedDisplayBox.
  48.     "oldDispBox center = p ifTrue: [^self]."
  49.     newDispBox _ oldDispBox align: oldDispBox center with: p.
  50.     "mode erase."
  51.     mode setUnclippedDisplayBox: newDispBox.
  52.     Display reverse: mode displayBox.
  53.     "mode setVisible: true.
  54.     mode displayBackgroundOn: Display in: nil"]! !
  55.  
  56. !ResizeDot methodsFor: 'private'!
  57.  
  58. on: aMode withMessage: aMsg 
  59.     "The position of self is computed according to aMsg.  Shan June 13, 
  60.     1989 "
  61.  
  62.     resizingMode _ aMode.
  63.     controlMessage _ aMsg! !
  64. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  65.  
  66. ResizeDot class
  67.     instanceVariableNames: ''!
  68.  
  69.  
  70. !ResizeDot class methodsFor: 'instance creation'!
  71.  
  72. on: aMode withMessage: aMsg 
  73.     "aMode is the mode that is resized.  aMsg is the message that should 
  74.     be sent to the controller of aMode when left mouse button is pressed 
  75.     on me.  Shan June 12, 1989"
  76.  
  77.     ^self new on: aMode withMessage: aMsg! !
  78.  
  79. SemanticObject subclass: #ResizeBackground
  80.     instanceVariableNames: 'clientMode '
  81.     classVariableNames: ''
  82.     poolDictionaries: ''
  83.     category: 'Resize-Shan'!
  84.  
  85.  
  86. !ResizeBackground methodsFor: 'controller-msg'!
  87.  
  88. action: e 
  89.     "RemoveÖself and the resize dots.  Return to the normal state.  Shan   
  90.     June 12, 1989"
  91.  
  92.     | box topMode |
  93.     clientMode map.  "Shan June 23, 1989"
  94.     box _ mode firstSubMode displayBox expandBy: 3 @ 3.
  95.     topMode _ mode topMode.
  96.     mode removeFromSuperMode.
  97.     topMode displayIn: box.
  98.     mode release! !
  99.  
  100. !ResizeBackground methodsFor: 'MMS-initializations'!
  101.  
  102. defaultMMSControllerClass
  103.     "Shan September 16, 1989"
  104.  
  105.     ^ActionController!
  106.  
  107. setUpMode
  108.     "Shan June 12, 1989"
  109.  
  110.     | rs |
  111.     mode _ ExpandedMode new.
  112.     mode setPainter: true.
  113.     mode semanticObject: self.
  114.     rs _ ResizeStyle new.
  115.     rs originX: #fixed.
  116.     rs originY: #fixed.
  117.     rs cornerY: #fixed.
  118.     rs cornerX: #fixed.
  119.     rs matchViewportWindow: true.
  120.     mode resizeStyle: rs! !
  121.  
  122. !ResizeBackground methodsFor: 'private'!
  123.  
  124. on: aMode
  125.     clientMode _ aMode! !
  126.  
  127. !ResizeBackground methodsFor: 'initialize-release'!
  128.  
  129. release
  130.     "Shan June 23, 1989"
  131.  
  132.     "Break the dependency."
  133.     mode subModes do: [:each | clientMode removeDependent: each semanticObject].
  134.     super release! !
  135. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  136.  
  137. ResizeBackground class
  138.     instanceVariableNames: ''!
  139.  
  140.  
  141. !ResizeBackground class methodsFor: 'instance creation'!
  142.  
  143. on: aMode
  144.     ^self new on: aMode! !
  145.  
  146. !ResizeBackground class methodsFor: 'memory management'!
  147.  
  148. private
  149.     "Shan June 13, 1989"
  150.  
  151.     "ResizeDot allInstances do: [: each | each nilFields] 
  152.     ResizeProxy allInstances do: [: each | each nilFields]. 
  153.     ResizeBackground allInstances  do: [: each | each release] 
  154.     ActionController allInstances  do: [: each | each nilFields] 
  155.     RootMode allInstances do: [: each | Smalltalk quickPointersTo: each 
  156.     do: [:pt| pt _ nil]] 
  157.     Mode allInstances  do: [: each | each breakDependents]"! !
  158.  
  159. ResizeBackground subclass: #ResizeProxy
  160.     instanceVariableNames: ''
  161.     classVariableNames: ''
  162.     poolDictionaries: ''
  163.     category: 'Resize-Shan'!
  164. ResizeProxy comment:
  165. 'This is a proxy of the mode being resized.  It is necessary to handle the move aspect of the interaction.  It simply detects the user button press and pass the responsibility of moving to the real mode.  Shan June 13, 1989'!
  166.  
  167.  
  168. !ResizeProxy methodsFor: 'controller-msg'!
  169.  
  170. action: e 
  171.     "Shan June 12, 1989"
  172.  
  173.     clientMode controller perform: #moveImage.
  174.     clientMode displayBox ~= mode displayBox ifTrue: [clientMode changed: #moveResized]! !
  175.  
  176. !ResizeProxy methodsFor: 'updating'!
  177.  
  178. update: x 
  179.     "This is sent when the clientMode is moved or resized.  Shan June  
  180.     13, 1989"
  181.  
  182.     x = #moveResized ifTrue: [mode setUnclippedDisplayBox: clientMode unclippedDisplayBox]! !
  183. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  184.  
  185. ResizeProxy class
  186.     instanceVariableNames: ''!
  187.  
  188.  
  189. !ResizeProxy class methodsFor: 'instance creation'!
  190.  
  191. on: aMode
  192.     "Shan June 13, 1989"
  193.     ^self new on: aMode! !
  194.  
  195. OpaqueController1 subclass: #ActionController
  196.     instanceVariableNames: ''
  197.     classVariableNames: 'ActionControllerERD '
  198.     poolDictionaries: ''
  199.     category: 'Resize-Shan'!
  200.  
  201. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  202.  
  203. ActionController class
  204.     instanceVariableNames: ''!
  205.  
  206.  
  207. !ActionController class methodsFor: 'initialize'!
  208.  
  209. ERDinit
  210.  
  211.     ActionControllerERD _ super eventResponsesDict deepCopy.
  212.     ActionControllerERD at: #leftButtonDown put: #action:.! !
  213.  
  214. !ActionController class methodsFor: 'access'!
  215.  
  216. eventResponsesDict
  217.     ^ ActionControllerERD! !